/**
 * Copyright (c) 2013-2022 Nikita Koksharov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.redisson.client.protocol.convertor;

import java.util.Collections;


/**
 * 实现了Convertor接口，用于将传入的对象转换为空集合或直接返回该对象。
 * 该转换器的主要作用是处理null值，将其转换为一个空集合，而非null值则直接返回。
 */
public class EmptySetConvertor implements Convertor<Object> {

    /**
     * 转换给定的对象。
     * 如果对象为null，则返回一个空集合；否则直接返回该对象。
     *
     * @param obj 待转换的对象。
     * @return 转换后的对象，如果原对象为null，则返回一个空集合。
     */
    @Override
    public Object convert(Object obj) {
        if (obj == null) {
            return Collections.emptySet();
        }
        return obj;
    }

}
